// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
/* eslint-disable */
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-default/index.css' // 默认主题
import axios from 'axios'
import 'font-awesome/css/font-awesome.css';

Vue.config.productionTip = false
Vue.use(ElementUI)
Vue.prototype.$axios = axios;
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  template: '<App/>',
  components: {
    App
  },
  created() {
    this.checkLogin()
  },
  watch: {
    "$route": 'checkLogin'
  },
  methods: {
    checkLogin() {
      if (this.$router.path == "/register")
        return;
      if (!localStorage.getItem('user.id')) {
        this.$router.push('/login')
      }
    }
  }

})
